package ui.viewModel.systemManagement;

import java.util.ArrayList;
import java.util.List;

import android.util.Log;

import ui.viewModel.ModelErrorInfo;
import ui.viewModel.ViewModel;

public class LoginViewModel extends ViewModel {

	// 调试用字符串
	private static String Tag = "LoginViewModel";

	// 声明了登录界面中跟用户交互时用到的变量
	private String userName, passWord;

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getPassWord() {
		return passWord;
	}

	public void setPassWord(String passWord) {
		this.passWord = passWord;
	}

	// 对用户输入的信息进行判断处理
	@Override
	public List<ModelErrorInfo> verifyModel() {
		// TODO Auto-generated method stub
		List<ModelErrorInfo> errs = null;
		if (userName == null) {
			ModelErrorInfo err = new ModelErrorInfo();
			err.setErrAttName(userName);
			err.setErrMsg("用户名不能为空");
			if (errs == null) {
				errs = new ArrayList<ModelErrorInfo>();
			}
			errs.add(err);
		}
		else if(userName.length() < 3){
			ModelErrorInfo err = new ModelErrorInfo();
			err.setErrAttName(userName);
			err.setErrMsg("用户名不能小于3");
			if (errs == null) {
				errs = new ArrayList<ModelErrorInfo>();
			}
			errs.add(err);
		}
		if (userName.length() > 8) {
			ModelErrorInfo err = new ModelErrorInfo();
			err.setErrAttName(userName);
			err.setErrMsg("用户名长度不能大于8");
			if (errs == null) {
				errs = new ArrayList<ModelErrorInfo>();
			}
			errs.add(err);
		}
		return errs;
	}

}
